const axios = require('axios')

axios.interceptors.response.use(function (response) {
  return response.data;
}, function (error) {
  return Promise.reject(error);
});

module.exports = {
  /*
   *@Description: 工程get请求方法
   *@params: 
   *@Author:  lupan
   *@Date: 2019-08-04 16:59:32
  */
  get: (url, params) => {
    return new Promise((reslove, reject) => {
      axios.get(url, {
        params: params
      }).then(res => {
        reslove(res)
      }).catch(err => {
        reject(err)
      })
    })
  },
  /*
   *@Description: 工程post请求方法
   *@params: 
   *@Author:  lupan
   *@Date: 2019-08-04 16:59:45
  */
  post: (url, params) => {
    return new Promise((reslove, reject) => {
      axios.post(url, params).then(res => {
        reslove(res)
      }).catch(err => {
        reject(err)
      })
    })
  }
}